# coding:utf-8
# filename:yangsy.py
from selenium import webdriver
import time
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.chrome.options import Options


file_path = 'D:/Day08/Day52/selenium.html'

Chrome_options = Options()
Chrome_options.add_experimental_option('debuggerAddress','127.0.0.1:9222')
driver = webdriver.Chrome(options=Chrome_options)
driver.get(file_path)

# 获取元素并传值
name = driver.find_element_by_css_selector('div#signup input[name="username"]')
password = driver.find_element_by_css_selector('div#signup input[name = "password"]')
city = driver.find_element_by_css_selector('div#signup select[name="city"]')
rem = driver.find_element_by_css_selector('div#signup input[name ="remeber"]')
mul = driver.find_element_by_css_selector('div#signup input[name = "multi_login"]')

name.send_keys('rabbit')
password.send_keys('love')
mul.click()
Select(city).select_by_value('sz')
time.sleep(3)
driver.find_element_by_xpath('//*[@id="signup"]/form/input[5]').click()
time.sleep(3)

sign = WebDriverWait(driver,10,0.5).until(
    lambda x: x.find_element_by_css_selector('div#signup').text == "注册成功")

driver.close()
driver.quit()

